package com.currency.mall.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.currency.mall.R;
import com.currency.mall.entity.BannerBean;
import com.currency.mall.loader.GlideImageLoader;
import com.youth.banner.Banner;
import com.youth.banner.listener.OnBannerListener;

import java.util.List;

/**
 * Created by Administrator on 2018/12/5.
 */

public class BannerAdapter extends BaseQuickAdapter<BannerBean, BaseViewHolder> {

    public BannerAdapter(@Nullable List<BannerBean> data, Context context) {
        super(R.layout.item_banner, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, BannerBean item) {
        ImageView img = helper.getView(R.id.img);
        Banner banner = helper.getView(R.id.banner);
        final List<BannerBean.BannerInfo>  bannerBeanList = item.getBanners();
        banner.setImages(bannerBeanList)
                .setImageLoader(new GlideImageLoader())
                .setDelayTime(5000)
                .setOnBannerListener(new OnBannerListener() {
                    @Override
                    public void OnBannerClick(int i) {
                        String actionUrl = bannerBeanList.get(i).getActionUrl();
                        if (!TextUtils.isEmpty(actionUrl)) {
//                                ToIntentUtil.toCommonIntent(bannerBeanList.get(i).getActionUrl(),mContext);
                        }
                    }
                })
                .start();
    }
}
